﻿using System;
using Microsoft.Extensions.DependencyInjection;

namespace ABlog.Domain.Core
{
    /// <summary>
    /// 容器管理
    /// </summary>
    public class ContainerManager
    {
        private static IServiceProvider _serviceProvider;

        public ContainerManager(IServiceProvider serviceProvider)
        {
            _serviceProvider = serviceProvider;
        }

        /// <summary>
        /// 得到实例
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static T GetInstance<T>()
        {
            return _serviceProvider.GetService<T>();
        }
    }
}
